package multithreading;

public class ticketThread extends Thread {
    static int ticket = 0;

    @Override
    public void run() {
        while (true) {
            synchronized (ticketThread.class) {
                if (ticket < 100) {
                    ticket++;
                    System.out.println(this.getName() + "ticket:" + ticket);
                    try {
                        this.sleep(100);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                } else {
                    break;
                }
            }
        }
    }
}
